package com.happyfamily.springboot.crowdsourcingplatform.dao.sun;

import com.happyfamily.springboot.crowdsourcingplatform.model.Work;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface WorkDao
{
	@Select("SELECT * FROM work WHERE wuseraccount=#{uaccount} AND consumeraccount IS NULL" +
			" ORDER BY wstarttime LIMIT #{limit} OFFSET #{end}")
	public abstract List<Work> getList(Integer limit,Integer end,String uaccount);

	@Select("SELECT COUNT(*) FROM work WHERE wuseraccount=#{uaccount} AND wendtime IS NULL")
	public abstract int getSum(String uaccount);

	@Delete("DELETE FROM work WHERE wid=#{wid}")
	public abstract int deleteWork(Integer wid);

	@Insert("INSERT INTO work (wuseraccount,wtitle,wcontent,wmoney,fname,wstarttime,type,wreadcount,wstatus) " +
			"VALUES (#{wuseraccount},#{wtitle},#{wcontent},#{wmoney},#{fname},#{wstarttime},#{type},'0','待审核')")
	public abstract int addWork(Work work);
}